#ifndef __CPPLINKTREE_H
#define __CPPLINKTREE_H
#define TreeElementType  void*
#include "CppDLlist.h"

class TreeNode
{
public:
    TreeNode(TreeElementType element,void(*CLearPtr)(TreeElementType));
    friend class LinkTree;
    void TravelTreeNode(int deepth,void(*funcptr)(ElementType));
    void ConnectBranch(TreeNode* parent);
    void DisconnectBranch(TreeNode* parent,TreeNode* child);
    int GetNodeHeight();
    TreeNode* SearchChildNode_LinkTree(void* value,bool(*funcptr)(void*,void*));
    ElementType GetNodeData();
private:
    TreeElementType data;
    TreeNode* parent;  //双亲结点
    DoubleLinkList children;  //孩子结点列表
    TreeNode* FindTreeNode(void* value,bool(funcptr)(void*,void*));
};
using TNode = TreeNode;

class LinkTree
{
public:
    LinkTree(void(*CLearPtr)(TreeElementType));
    TreeNode* GetTreeRoot();
    void TravelTree_LTree(void(*funcptr)(ElementType));
    int GetTreeHight();
    TreeNode* SearchNode_LinkTree(void* value,bool(*funcptr)(void*,void*));
    
    
private:
    TreeNode* rootnode;
};
using LTree = LinkTree;





#endif
